package main

import (
	"fmt"
	"math/rand"
	"time"
)

// 随机生成20以内的20个非0正整数，打印出来。对生成的数值，第单数个（不是索引）累加求和，第偶数个累乘求积。打印结果
func main() {
	sum := 0
	mul := 1

	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	for i := 0; i < 20; i++ {
		num := r.Intn(20) + 1
		fmt.Printf("第 %d 个随机数是 %d\n", i+1, num)
		if i%2 == 0 {
			sum += num
		} else {
			mul *= num
		}
	}
	fmt.Println("sum =", sum)
	fmt.Println("mul =", mul)
}
